﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UIBase : MonoBehaviour
{
    [SerializeField]
    UnlimitedLoopList unlimitedLoopList;
    [SerializeField]
    protected List<Toggle> toggles = new List<Toggle>();
    List<List<string>> list_StrList = new List<List<string>>();
    List<string> showList = new List<string>();
    // Use this for initialization
    void Start()
    {
        for (int i = 0; i < toggles.Count; i++)
        {
            int index = i;
            toggles[i].onValueChanged.AddListener((bool ison) => { if (ison) ChangeShowingList(index); });
            toggles[i].transform.Find("Label").GetComponent<Text>().text = "显示：" + (i + 1).ToString();
            List<string> vs = new List<string>();
            string str = "";
            for (int j = 0; j < 100; j++)
            {
                str = string.Format("列表名：" + (i+1).ToString() + ";" + "序号：" + j.ToString() + ".");
                vs.Add(str);
            }
            list_StrList.Add(vs);
        }
        if (unlimitedLoopList != null)
        {
            showList = list_StrList[0];
            unlimitedLoopList.Init(list_StrList[0]);
            unlimitedLoopList.Move_m_Rect_ToTopAndRefreshItem();
        }
    }
    private void ChangeShowingList(int index)
    {
        showList = list_StrList[index];
        unlimitedLoopList.Init(list_StrList[index]);
        unlimitedLoopList.Move_m_Rect_ToTopAndRefreshItem();
    }
    protected void UpdateItemInfo(int index, GameObject item)
    {
        item.transform.Find("Text").GetComponent<Text>().text = showList[index];
    }
}
